package com.example.demo.kitchen.messaging.jms

import com.example.demo.data.Order
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.jms.core.JmsTemplate
import org.springframework.stereotype.Component

interface OrderMessageService {
    fun sendOrder(order: Order)
}

@Component
class JmsOrderReceiver @Autowired constructor(
        private val jms: JmsTemplate
): OrderMessageService {

    override fun sendOrder(order: Order) {
//        jms.send(orderQueue) { session -> session.createObjectMessage(order) }
        jms.convertAndSend(DESTINATION, order)
    }

    companion object {
        private const val DESTINATION = "localhost:8161"
    }
}